const express = require('express');
const app = express();
const path = require('path');
const {router,socket} = require('./server');
const cors = require('cors');
console.log('Listening on port 8080');
app.use(cors());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/',router);
app.all('*', function (req, res, next) {
    res.header('Access-Control-Allow-Origin', "*");
    res.header('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type');
    res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
    next();
});
const server = app.listen(8080, (error) => {
    if (error) {
        console.error(error);
    } else {
        console.info('==> Listening on port %s. Open up http://localhost:%s/ in your browser.', 8080, 8080);
    }
});
socket(server);
